//==========================================================================================
//
//	eisfaust.gm
//
//	Who                    	When		What
//------------------------------------------------------------------------------------------
//	^1{WeB}^7*^4GA^1NG$^4TA^7*	24 September 2016	Initial Script
//
//==========================================================================================
//

global Map =
{
	Debug = 1, // please set to zero before distributing your script
	ShowMovers = false,

	Bergmauer_Dyno = 0,
	Neutral_Command_Post_Dyno = 0,
	Provisorische_Bruecke_Dyno = 0,
	Ufer_MG_Dyno = 0,
	V2_Rakete_Dyno = 0,
	Westturm_Dyno = 0,

	Neutral_Command_Post_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		
		Util.MapDebugPrint( "Neutral_Command_Post_Built" );
	},

	Provisorische_Bruecke_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Ufer_MG" );	

		Util.MapDebugPrint( "Provisorische_Bruecke_Built" );
	},

	Ufer_MG_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }
				

		Util.MapDebugPrint( "Ufer_MG_Built" );
	},

	Westturm_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Provisorische_Bruecke" );	

		Util.MapDebugPrint( "Westturm_Built" );
	},

	Bergmauer_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Westturm" );	

		Map.Bergmauer_Dyno += 1;
		Util.MapDebugPrint( "Bergmauer_Planted" );
	},

	Neutral_Command_Post_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Neutral_Command_Post_Dyno += 1;
		Util.MapDebugPrint( "Neutral_Command_Post_Planted" );
	},

	Provisorische_Bruecke_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Provisorische_Bruecke_Dyno += 1;
		Util.MapDebugPrint( "Provisorische_Bruecke_Planted" );
	},

	Ufer_MG_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Ufer_MG_Dyno += 1;
		Util.MapDebugPrint( "Ufer_MG_Planted" );
	},

	V2_Rakete_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.V2_Rakete_Dyno += 1;
		Util.MapDebugPrint( "V2_Rakete_Planted" );
	},

	Westturm_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Westturm_Dyno += 1;
		Util.MapDebugPrint( "Westturm_Planted" );
	},

	Bergmauer_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Bergmauer_Dyno -= 1;
		Util.MapDebugPrint( "Bergmauer_Defused" );
	},

	Neutral_Command_Post_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Neutral_Command_Post_Dyno -= 1;
		Util.MapDebugPrint( "Neutral_Command_Post_Defused" );
	},

	Provisorische_Bruecke_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Provisorische_Bruecke_Dyno -= 1;
		Util.MapDebugPrint( "Provisorische_Bruecke_Defused" );
	},

	Ufer_MG_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Ufer_MG_Dyno -= 1;
		Util.MapDebugPrint( "Ufer_MG_Defused" );
	},

	V2_Rakete_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.V2_Rakete_Dyno -= 1;
		Util.MapDebugPrint( "V2_Rakete_Defused" );
	},

	Westturm_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Westturm_Dyno -= 1;
		Util.MapDebugPrint( "Westturm_Defused" );
	},

	Bergmauer_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Bergmauer_Dyno = 0;

		Util.MapDebugPrint( "Bergmauer_Destroyed" );
	},

	Neutral_Command_Post_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Neutral_Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Neutral_Command_Post_Destroyed" );
	},

	Provisorische_Bruecke_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Provisorische_Bruecke_Dyno = 0;

		Util.MapDebugPrint( "Provisorische_Bruecke_Destroyed" );
	},

	Ufer_MG_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Ufer_MG_Dyno = 0;

		Util.MapDebugPrint( "Ufer_MG_Destroyed" );
	},

	V2_Rakete_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.V2_Rakete_Dyno = 0;

		Util.MapDebugPrint( "V2_Rakete_Destroyed" );
	},

	Westturm_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Westturm_Dyno = 0;

		Util.MapDebugPrint( "Westturm_Destroyed" );
	},
	
		Festungsmauer_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

	       SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_V2_Rakete" );
		 SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Rocket_1" );
	       SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Rocket_2" );
	       SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Rocket_3" );
		 SetAvailableMapGoals( TEAM.ALLIES, false, "CAMP_Hillside_1" );
		 SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Provisorische_Bruecke" );
		 SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Ufer_MG" );
		 SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Rocket_1" );
	       SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Rocket_2" );
	       SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Rocket_3" );
		 SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_wall_1" );
		 SetAvailableMapGoals( TEAM.AXIS, false, "FLAG_V2_Dokumente" );
		 SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Neutral_Command_Post" );
		 SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Neutral_Command_Post" );
		 SetAvailableMapGoals( TEAM.AXIS, false, "CHECKPOINT_forwardspawn1_flag" );

		Util.MapDebugPrint( "Festungsmauer_Destroyed" );
	},

	V2_Dokumente_Taken = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "V2_Dokumente_Taken" );
	},

	V2_Dokumente_Returned = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "V2_Dokumente_Returned" );
	},

	V2_Dokumente_Secured = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.AXIS, false, "CAPPOINT_Funkraum" );	

		Util.MapDebugPrint( "V2_Dokumente_Secured" );
	},

	forwardspawn1_flag_Axis_Captured = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "forwardspawn1_flag_Axis_Captured" );
	},

	forwardspawn1_flag_Allies_Captured = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Neutral_Command_Post" );	
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Festungsmauer" );	


		Util.MapDebugPrint( "forwardspawn1_flag_Allies_Captured" );
	},

};

global OnMapLoad = function()
{
	if ( TestMapOn )
		{ Util.AutoTestMap(); }

	// Register callback functions
	OnTrigger( "Die Aliierten haben die provisorische Bruecke repariert!.", Map.Provisorische_Bruecke_Built );
	OnTrigger( "Die Allies haben das Ufer-MG errichtet!", Map.Ufer_MG_Built );
	OnTrigger( "Die Aliierten haben den Westturm gebaut!.", Map.Westturm_Built );
	OnTrigger( "Die Aliierten haben die Bergmauer gesprengt!", Map.Bergmauer_Destroyed );
	OnTrigger( "Die Aliierten haben die Festungsmauer gesprengt!", Map.Festungsmauer_Destroyed );
	OnTrigger( "Die provisorische Bruecke wurde von den Deutschen gesprengt.", Map.Provisorische_Bruecke_Destroyed );
	OnTrigger( "MISSING_STRING", Map.V2_Rakete_Destroyed );
	OnTrigger( "Der Westturm wurde von den Deutschen gesprengt.", Map.Westturm_Destroyed );
	OnTrigger( "Planted at Bergmauer.", Map.Bergmauer_Planted );
	OnTrigger( "Axis have stolen V2 Dokumente!", Map.V2_Dokumente_Taken );
	OnTrigger( "Die Allies haben die V2 rechtzeitig gesprengt!", Map.V2_Dokumente_Returned );
	OnTrigger( "Dokumente wurden uebermittelt. Noch 5 Minuten bis zum Start der V2!", Map.V2_Dokumente_Secured );
	OnTrigger( "Die Axis haben die Ruine eingenommen!", Map.forwardspawn1_flag_Axis_Captured );
	OnTrigger( "Die Allies haben die Ruine eingenommen!", Map.forwardspawn1_flag_Allies_Captured );
	
	SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Neutral_Command_Post" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Provisorische_Bruecke" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Ufer_MG" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Westturm" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Festungsmauer" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_V2_Rakete" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNTMG42_360" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "REPAIRMG42_360" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Rocket_1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Rocket_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Rocket_3" );
	SetAvailableMapGoals( TEAM.AXIS, false, "MOUNTMG42_360" );
	SetAvailableMapGoals( TEAM.AXIS, false, "REPAIRMG42_360" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Rocket_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Rocket_2" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Rocket_3" );
	
	SetGoalPriority("PLANT_Bergmauer", 0.91);
	SetGoalPriority("BUILD_Provisorische_Bruecke", 0.91);
	SetGoalPriority("BUILD_Ufer_MG", 0.91);
	SetGoalPriority("PLANT_Festungsmauer", 0.91);
	SetGoalPriority("CAMP_Hillside_1", 0.91);

	
	//~Util.DisableGoal( ".*", true ); // all but routes
	//~SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_.*" );
	//~SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_.*" );

	// Max users per goal
	//Util.SetMaxUsers( 1, "DEFEND_.*" );
	//Util.SetMaxUsers( 1, "GRENADE_.*" );
	//Util.SetMaxUsers( 1, "MOUNTMG42_.*" );

	// Camp times
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=15, MaxCampTime=90} );
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=10, MaxCampTime=60} );


	Util.MapDebugPrint( "Omni-bot map script for " + GetMapName() + " executed." );
};

global OnBotJoin = function( bot )
{
	
	  bot.TargetBreakableDist = 90.0;
	// Only set MaxViewDistance on maps with limited sight (e.g. fog)
	//~bot.MaxViewDistance = 2400;
};

global InitializeRoutes = function()
{
	MapRoutes =
	{
		BUILD_Neutral_Command_Post =
		{
		},
		BUILD_Westturm =
		{
		},
		BUILD_Ufer_MG =
		{
		},
		BUILD_Provisorische_Bruecke =
		{
		},
		PLANT_Provisorische_Bruecke =
		{
		},
		PLANT_Neutral_Command_Post =
		{
		},
		PLANT_Westturm =
		{
		},
		PLANT_Ufer_MG =
		{
		},
		PLANT_Bergmauer =
		{
		},
		PLANT_V2_Rakete =
		{
		},
		FLAG_V2_Dokumente =
		{
		},
		CHECKPOINT_forwardspawn1_flag =
		{
		},
	};
	Util.Routes(MapRoutes);
};
